#coding:utf-8
from flask import Flask
from flask import render_template
from flask import request
from flask import jsonify
from context import get_data
from context import ping_host
app = Flask(__name__)

@app.route('/')
def hello_world():
    return render_template('hello.html', name='the word!')

@app.route('/ping2')
def ping2():
    return render_template('ping2.html')

@app.route('/ping')
def ping():
    return render_template('ping.html')

@app.route('/pinglog',methods=['GET'])
def pinglog():
    datetime=request.args.get('data_date')
    data=get_data(datetime)
    return jsonify(data),200

@app.route('/pingsvr',methods=['GET'])
def pingsvr():
    svr=request.args.get('server')
    data=ping_host(svr)
    return jsonify(data)
if __name__ == '__main__':
    app.run(host='0.0.0.0')
